﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using StructureMap;
using System.Web.Routing;

namespace Universum.Infrastructure.Configuration
{
	/// <summary>
	/// Matches an incoming request with the appropriate controller
	/// </summary>
	public class StructureMapControllerFactory : DefaultControllerFactory
	{
		public override IController CreateController(RequestContext context, string controllerName)
		{

			Type controllerType = base.GetControllerType(controllerName);
			if (controllerType == null) return null;
			return ObjectFactory.GetInstance(controllerType) as IController;
		}
	}
}
